Skip to content

[Ready for review] Hessian for elementwise multiplication#6

Merged
dance858 merged 4 commits intomainfrom
multiply_hess
Jan 6, 2026
Merged

[Ready for review] Hessian for elementwise multiplication#6
dance858 merged 4 commits intomainfrom
multiply_hess

Conversation

@dance858
Copy link
Collaborator

@dance858 dance858 commented Jan 5, 2026

This PR is work in progress, so no need to review it yet.

Adds hessian for elementwise multiplication. For correctness it assumes that either

  1. both arguments are variables and they are different
  2. both arguments are linear operators

For example, it can't handle multiply(x, x) where both x are vectors, so in the DNLP canon file of multiply we could check if both arguments are variables and if yes we instead canonicalize it to power. (We do similar checks for rel_entr, which we canonicalize using log if one of the arguments is a constant.)

The code can handle multiply(Ax, Ax) though, where A has global column indices

@dance858 dance858 changed the title [WIP] Hessian for elementwise multiplication [Ready for review] Hessian for elementwise multiplication Jan 5, 2026
Copy link
Collaborator

@Transurgeon Transurgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Had a few comments/questions once again, but feel free to merge :).

expr *y = node->right;

/* for correctness x and y must be (1) different variables,
or (2) both must be linear operators */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not have (Ax) * y? as long as they have the same shape? So not necessarily both linear operators?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we don't support this, because the second argument must be a "global" linear operator for the product rule to be correct. But we can form the B matrix representing y internally if only the left node is a linear operator. I'll add this as an issue so we do this later.

@dance858 dance858 merged commit 868e1cd into main Jan 6, 2026
9 checks passed
@dance858 dance858 deleted the multiply_hess branch January 8, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants